//
//  ViewController.m
//  ObjcGo
//
//  Created by eport on 2021/1/29.
//

#import "ViewController.h"
#import "CopyViewController.h"
#import "AViewController.h"
#import "TimerViewController.h"
#import "GCDViewController.h"
static NSString *iden_cell = @"iden_cell";

@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,strong)UITableView *tableview;
@property(nonatomic,strong)NSArray *array;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"首页";
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.array = @[@"深浅拷贝",@"生命周期",@"timer",@"多度单写"];
    
    [self _initTableviews];
    
    
   
    
}


-(void)_initTableviews{
    self.tableview = [[UITableView alloc]initWithFrame:self.view.bounds style:(UITableViewStyleGrouped)];
    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    [self.view addSubview:self.tableview];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.array.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:iden_cell];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:iden_cell];
    }
    cell.textLabel.text = self.array[indexPath.row];
    return cell;
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSString *text = self.array[indexPath.row];
    if ([text isEqualToString:@"深浅拷贝"]) {
        CopyViewController *copy = [[CopyViewController alloc]init];
        [self.navigationController pushViewController:copy animated:YES];
    }else if([text isEqualToString:@"生命周期"]){
        AViewController *copy = [[AViewController alloc]init];
        [self.navigationController pushViewController:copy animated:YES];
        
    }else if([text isEqualToString:@"timer"]){
        TimerViewController *copy = [[TimerViewController alloc]init];
        [self.navigationController pushViewController:copy animated:YES];
    }
    else if([text isEqualToString:@"多度单写"]){
        GCDViewController *copy = [[GCDViewController alloc]init];
        [self.navigationController pushViewController:copy animated:YES];
    }
    
    //
}



@end
